package Greed;

public class OptimalDivision {
    public String optimalDivision(int[] nums) {
        int len = nums.length;
        StringBuilder ret = new StringBuilder();
        if (len == 1) {
            return ret.append(nums[0]).toString();
        }
        if (len == 2) {
            return ret.append(nums[0]).append("/").append(nums[1]).toString();
        }
        ret.append(nums[0]).append("/(").append(nums[1]).toString();
        for (int i = 2; i < len; i++) {
            ret.append("/").append(nums[i]);
        }
        ret.append(")");
        return ret.toString();
    }
}